package com.baidu.file;

import java.io.File;

public class D04_FileForeach {
    public static void main(String[] args) {
        File file = new File("src");

        //遍历目录下文件获取名字
        String[] list = file.list();
        for (String s : list) {
            System.out.println(s);
        }

        //遍历目录获取所有文件对象
        File[] files = file.listFiles();
        for (File fileObj : files) {
            System.out.println(fileObj.getName());
        }

    }

}
